package com.hzlh.mq;
import com.hzlh.common.Constants;
import com.hzlh.configuration.RabbitConfig;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfiguration {

    @Bean("defaultDirect")
    public DirectExchange directExchange(){
        return new DirectExchange(Constants.MQ_DIRECT,true,false);
    }

    @Bean("queueB")
    public Queue queueB(){
        return new Queue(RabbitConfig.QUEUE_A,true);
    }
    @Bean("bindQueueB")
    public Binding bindingA(@Qualifier("defaultDirect") DirectExchange directExchange, @Qualifier("queueB") Queue queue){
        return BindingBuilder.bind(queue).to(directExchange).with(Constants.MQ_ROUTING_KEY_XXX);
    }

}
